import QtQuick 2.0

Rectangle {
    id: heartrate
    width: 100
    height: 62
    signal postClicked
    property string bpm: "0"
    property string ibi: "0"
    property string temp: "0"

    Chart {
        id:chart
        anchors.top:parent.top
        anchors.topMargin: 20
        anchors.left: parent.left
        anchors.leftMargin: 20
        anchors.right: showitem.left
        anchors.rightMargin: 20
        //anchors.bottom: parent.bottom
        anchors.bottomMargin: 20
    }
    Item {
        id: showitem
        width: 150
        height: chart.height
        property int marSize: (height - 68 * 3) / 2
        anchors{
            top: parent.top
            topMargin: 20
            right: parent.right
        }
        Text {
            id:showbpm
            font.family: "Open Sans"
            font.pixelSize: 25
            font.weight: Font.DemiBold
            text: "心率:"
        }
        Text {
            id:showbpmdata
            anchors.top: showbpm.bottom
            anchors.topMargin: 13
            anchors.left: parent.left
            anchors.leftMargin: 20
            font.family: "Open Sans"
            font.pixelSize: 30
            font.weight: Font.DemiBold
            text: heartrate.bpm
        }

        Text {
            id:showibi
            anchors.top: showbpmdata.bottom
            anchors.topMargin: showitem.marSize
            font.family: "Open Sans"
            font.pixelSize: 25
            font.weight: Font.DemiBold
            text: "心率间隔:"
        }
        Text {
            id:showibidata
            anchors.top: showibi.bottom
            anchors.topMargin: 13
            anchors.left: parent.left
            anchors.leftMargin: 20
            font.family: "Open Sans"
            font.pixelSize: 30
            font.weight: Font.DemiBold
            text: heartrate.ibi
        }

        Text {
            id:showtemp
            anchors.top: showibidata.bottom
            anchors.topMargin: showitem.marSize
            font.family: "Open Sans"
            font.pixelSize: 25
            font.weight: Font.DemiBold
            text: "体温:"
        }
        Text {
            id:showtempdata
            anchors.top: showtemp.bottom
            anchors.topMargin: 13
            anchors.left: parent.left
            anchors.leftMargin: 20
            font.family: "Open Sans"
            font.pixelSize: 30
            font.weight: Font.DemiBold
            text: heartrate.temp
        }
    }



    Button {
        id: postButton
        anchors.top: chart.bottom
        anchors.topMargin: 30
        anchors.horizontalCenter: parent.horizontalCenter

        text: "Post"
        buttonEnabled:false
        onClicked: {
            heartrate.postClicked()
            buttonEnabled=!buttonEnabled
        }
    }

    function add_point(point) {
        chart.add_point(point)
    }
}

